<div class="content-wrapper">

    <section class="content-header">
        <?php echo $this->partial('layout/breadcrumb'); ?>

        <h1 class="pull-right">
            <a href="<?php echo $this->url('goods', ['action'=> 'add']);?>" class="btn btn-primary btn-sm"><i class="fa fa-plus"></i> <?php echo $this->translate('添加商品'); ?></a>
            <?php echo $this->HelpUrl('goodsList'); ?>
        </h1>

    </section>

    <section class="content">
        <?php echo $this->partial('layout/messages'); ?>

        <div class="row">
            <div class="col-xs-12">
                <div class="box shop-box">

                    <div class="box-body table-responsive no-padding">
                        <table class="table shop-table table-hover">
                            <thead>
                            <tr class="shop-bg-thead">
                                <th width="5%">ID</th>
                                <th width=""><?php echo $this->translate('商品名称'); ?></th>
                                <th width="10%"><?php echo $this->translate('商品货号'); ?></th>
                                <th width="10%"><?php echo $this->translate('商品价格'); ?></th>
                                <th width="10%"><?php echo $this->translate('主分类'); ?></th>
                                <th width="10%"><?php echo $this->translate('状态'); ?></th>
                                <th width="10%"><?php echo $this->translate('类型'); ?></th>
                                <th width="15%"><?php echo $this->translate('操作'); ?></th>
                            </tr>
                            <?php
                            $sForm = $this->searchForm;
                            $sForm->prepare();
                            $sForm->get('goods_state')->setEmptyOption('选择状态');
                            $sForm->get('goods_type')->setEmptyOption('选择类型');
                            ?>
                            <?php echo $this->form()->openTag($sForm); ?>
                            <tr>
                                <td>
                                    <p>
                                        <?php echo $this->formElement($sForm->get('start_id')); ?>
                                    </p>
                                    <div>
                                        <?php echo $this->formElement($sForm->get('end_id')); ?>
                                    </div>
                                    <?php echo $this->formElementErrors($sForm->get('start_id'), ['class'=>'error-message']);?>
                                    <?php echo $this->formElementErrors($sForm->get('end_id'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <?php echo $this->formElement($sForm->get('goods_name')); ?>
                                    <?php echo $this->formElementErrors($sForm->get('goods_name'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <?php echo $this->formElement($sForm->get('goods_item')); ?>
                                    <?php echo $this->formElementErrors($sForm->get('goods_item'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <p>
                                        <?php echo $this->formElement($sForm->get('start_price')); ?>
                                    </p>
                                    <div>
                                        <?php echo $this->formElement($sForm->get('end_price')); ?>
                                    </div>
                                    <?php echo $this->formElementErrors($sForm->get('start_price'), ['class'=>'error-message']);?>
                                    <?php echo $this->formElementErrors($sForm->get('end_price'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <?php echo $this->formElement($sForm->get('class_id')); ?>
                                    <?php echo $this->formElementErrors($sForm->get('class_id'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <?php echo $this->formElement($sForm->get('goods_state')); ?>
                                    <?php echo $this->formElementErrors($sForm->get('goods_state'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <?php echo $this->formElement($sForm->get('goods_type')); ?>
                                    <?php echo $this->formElementErrors($sForm->get('goods_type'), ['class'=>'error-message']);?>
                                </td>
                                <td>
                                    <button type="submit" class="btn btn-info btn-sm"><i class="fa fa-search"></i></button>
                                    <?php
                                    $formData = $sForm->getData();
                                    if(!empty(array_filter($formData))) { ?>
                                        &nbsp;&nbsp;<a href="<?php echo $this->url('goods');?>" class="btn btn-default btn-sm"><i class="fa fa-reply"></i></a>
                                    <?php } $formData['page'] = $this->goodsList->getCurrentPageNumber(); ?>
                                </td>
                            </tr>
                            <?php echo $this->form()->closeTag(); ?>
                            </thead>
                            <tbody>
                            <?php if($this->goodsList->getCurrentItemCount() > 0) foreach ($this->goodsList as $goodsValue) { ?>
                                <tr>
                                    <td><?php echo $goodsValue[0]->getGoodsId(); ?></td>
                                    <td>
                                        <img src="<?php echo $this->goodsHelper()->goodsImage($goodsValue['goodsThumbnailImage']); ?>" class="img-thumbnail" style="width: 50px;height: 50px;">
                                        <?php echo $this->escapeHtml($goodsValue[0]->getGoodsName()); ?>
                                    </td>
                                    <td><?php echo $this->escapeHtml($goodsValue[0]->getGoodsItem()); ?></td>
                                    <td><?php echo $this->shopCurrencyFormat($goodsValue[0]->getGoodsPrice()); ?></td>
                                    <td><?php echo $this->escapeHtml($goodsValue['className']); ?></td>
                                    <td><?php echo $this->goodsHelper()->goodsState($goodsValue[0]->getGoodsState()); ?></td>
                                    <td><?php echo $this->goodsHelper()->goodsType($goodsValue[0]->getGoodsType()); ?></td>
                                    <td>
                                        <p>
                                            <a href="<?php echo $this->url('goods',
                                                ['action'=>'edit', 'id'=>$goodsValue[0]->getGoodsId()], ['query' => $formData]); ?>"
                                               class="btn btn-xs btn-success"><i class="fa fa-pencil"></i> <?php echo $this->translate('编辑'); ?></a>
                                            <a href="javascript:;" onclick="deleteConfirm('<?php echo $this->translate('您确实要删除该商品吗?'); ?>', '<?php echo $this->url('goods', ['action'=>'delete', 'id'=>$goodsValue[0]->getGoodsId()], ['query' => ['qToken' => $this->adminHelper()->getCsrfValue()]]); ?>');" class="btn btn-xs btn-danger"><i class="fa fa-trash"></i> <?php echo $this->translate('删除'); ?></a>
                                        </p>
                                        <?php if ($goodsValue[0]->getGoodsType() == 2) { ?>
                                            <p>
                                                <a href="<?php echo $this->url('goods',
                                                    ['action'=>'editVirtualGoods', 'id'=>$goodsValue[0]->getGoodsId()], ['query' => $formData]); ?>"
                                                   class="btn btn-xs btn-success"><i class="fa fa-pencil"></i> <?php echo $this->translate('查看与补货'); ?></a>
                                            </p>
                                        <?php } ?>
                                    </td>
                                </tr>
                            <?php } ?>
                            </tbody>
                        </table>
                    </div>
                    <div class="box-footer clearfix">
                    <?php echo $this->paginationControl($this->goodsList, 'Sliding', 'layout/page', ['route' => 'goods']); ?>
                    </div>
                </div>
            </div>
        </div>

    </section>
</div>
<script>
    laydate.render({elem: '#start_time'});
    laydate.render({elem: '#end_time'});
</script>